package com.fanxuankai.ksql.function.udf.datetime;

import io.confluent.ksql.function.udf.Udf;
import io.confluent.ksql.function.udf.UdfDescription;
import io.confluent.ksql.function.udf.UdfParameter;

import java.sql.Date;
import java.sql.Timestamp;

/**
 * @author fanxuankai
 */
@UdfDescription(name = "get_time", description = "time", author = "fanxuankai")
public class Time {
    @Udf
    public java.sql.Time calc(@UdfParameter("val") Timestamp o) {
        return o == null ? null : new java.sql.Time(o.getTime());
    }

    @Udf
    public java.sql.Time calc(@UdfParameter("val") Date o) {
        return o == null ? null : new java.sql.Time(o.getTime());
    }

    @Udf
    public java.sql.Time calc(@UdfParameter("val") java.sql.Time o) {
        return o;
    }
}
